using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;


namespace GameWP
{
    public class FrontPlayerComponent : Microsoft.Xna.Framework.DrawableGameComponent
    {
        Game _game;
        private SpriteBatch _spriteBatch;
        private List<Layer> _listPlayer;

        //Initilation
        public FrontPlayerComponent(Game game, SpriteBatch spriteBatch, List<Texture2D> listTexture)
            : base(game)
        {
            _game = game;
            _spriteBatch = spriteBatch;
            //Init list menu item
            _listPlayer = new List<Layer>();
            for (int i = 0; i < listTexture.Count; i++)
            {
                List<Sprite2D> listSprite = new List<Sprite2D>();
                listSprite.Add(new Sprite2D(listTexture[i],Vector2.Zero));
                _listPlayer.Add(new Layer(listSprite,Vector2.Zero,ManagerGame.camera));
            }
            _listPlayer[0].Parallax = new Vector2(1.0f, 1.0f);
            //_listPlayer[1].Parallax = new Vector2(1.3f, 1.0f);
        }

        public override void Initialize()
        {
            // TODO: Add your initialization code here
                base.Initialize();
        }

        public override void Update(GameTime gameTime)
        {
            float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds;
            // TODO: Add your update code here    
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                _game.Exit();
            //Key input
        }

        public override void Draw(GameTime gameTime)
        {
            base.Draw(gameTime);
            for (int i = 0; i < _listPlayer.Count; i++)
                _listPlayer[i].Draw(_spriteBatch, gameTime);
        }
    }
}
